Subtract logical.x from x to fix the wrong position for right and center
authorJan Arne Petersen <jpetersen@jpetersen.org>
Sun, 25 May 2008 12:29:19 +0000 (12:29 +0000)
committerJan Arne Petersen <jap@src.gnome.org>
Sun, 25 May 2008 12:29:19 +0000 (12:29 +0000)
2008-05-25  Jan Arne Petersen  <jpetersen@jpetersen.org>

* gtk/gtklabel.c: (get_layout_location): Subtract logical.x from x to
fix the wrong position for right and center justified labels with
logical.x > 0 (#530255).

svn path=/trunk/; revision=20146

ChangeLog
gtk/gtklabel.c

index cfa0b4f4b821de0c0aedfe1446e96619b88e2c63..078d4a1320525263185d7b10925b39f12e13955e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-05-25  Jan Arne Petersen  <jpetersen@jpetersen.org>
+
+       * gtk/gtklabel.c: (get_layout_location): Subtract logical.x from x to
+       fix the wrong position for right and center justified labels with
+       logical.x > 0 (#530255).
+
 2008-05-25  Jan Arne Petersen  <jpetersen@jpetersen.org>
 
        * gtk/gtkfilechooserdefault.c:
index eb71103c6348829b53fa3b6cb5eb03e6f31425ae..0b86314fcb5e6cb685cef092760f4a03128e6ea3 100644 (file)
@@ -2661,6 +2661,7 @@ get_layout_location (GtkLabel  *label,
   GtkLabelPrivate *priv;
   gfloat xalign;
   gint req_width, x, y;
+  PangoRectangle logical;
   
   misc = GTK_MISC (label);
   widget = GTK_WIDGET (label);
@@ -2671,13 +2672,13 @@ get_layout_location (GtkLabel  *label,
   else
     xalign = 1.0 - misc->xalign;
 
+  pango_layout_get_pixel_extents (label->layout, NULL, &logical);
+
   if (label->ellipsize || priv->width_chars > 0)
     {
       int width;
-      PangoRectangle logical;
 
       width = pango_layout_get_width (label->layout);
-      pango_layout_get_pixel_extents (label->layout, NULL, &logical);
 
       req_width = logical.width;
       if (width != -1)
@@ -2694,6 +2695,7 @@ get_layout_location (GtkLabel  *label,
     x = MAX (x, widget->allocation.x + misc->xpad);
   else
     x = MIN (x, widget->allocation.x + widget->allocation.width - misc->xpad);
+  x -= logical.x;
 
   y = floor (widget->allocation.y + (gint)misc->ypad 
              + MAX (((widget->allocation.height - widget->requisition.height) * misc->yalign),